package cn.itcast.mapreduce.db.write;

import cn.itcast.mapreduce.db.bean.GoodsBean;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * todo 在使用DBoutputFormat的时候 要求输出的key必须是DBWritable的实现 因为只会把key写入数据库
 */
public class WriteDBReducer extends Reducer<NullWritable, GoodsBean, GoodsBean, NullWritable> {
    @Override
    protected void reduce(NullWritable key, Iterable<GoodsBean> values, Context context) throws IOException, InterruptedException {
        for (GoodsBean value : values) {
            context.write(value, key);
        }
    }
}
